package com.example.loginproject.view.fragments

import android.content.Intent
import android.os.Bundle
import android.provider.Telephony.Mms.Intents
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.example.loginproject.R
import com.example.loginproject.databinding.FragmentPinLoginBinding

import com.example.loginproject.tool.navigateTo
import com.example.loginproject.user.UserManager

/**
 * A simple [Fragment] subclass.
 * Use the [PinLoginFragment.newInstance] factory method to
 * create an instance of this fragment.
 */
class PinLoginFragment : Fragment() {
    private lateinit var binding:FragmentPinLoginBinding
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentPinLoginBinding.inflate(inflater, null, false)
        // Inflate the layout for this fragment
        return binding.root
    }
   override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
       //设置 切换到图案解锁的显示和隐藏
       if(UserManager.sharedInstance(requireContext()).hasUser()){
           binding.switchToPatternTextView.visibility = View.VISIBLE
       }else{
           binding.switchToPatternTextView.visibility = View.INVISIBLE
           //没有用户无法点击登录按钮
           binding.button.isEnabled = false
       }
       binding.titleTextView.setOnClickListener {
          //被点击了需要干什么
           navigateTo(PinRegisterFragment())
       }

    }
}